part of 'api.dart';

// ignore: library_private_types_in_public_api
extension ApiBlogger on _Api {
  ///获取博主的粉丝团
  Future<BloggerFansGroupModel?> queryFansGroupByUserId(int? userId) async {
    try {
      final resp = await httpInstance.get(
        url: 'bloggerFansGroup/queryFansGroupByUserId',
        queryMap: {'userId': userId},
        complete: BloggerFansGroupModel.fromJson,
      );

      return resp;
    } catch (e) {
      return null;
    }
  }

  ///获取粉丝团成员列表
  Future<List<BloggerFansModel>?> queryFansGroupUser({
    required int userId,
    required int page,
    required int pageSize,
  }) async {
    try {
      final resp = await httpInstance.get(
        url: 'bloggerFansGroup/queryFansGroupUser',
        queryMap: {'userId': userId, 'page': page, 'pageSize': pageSize},
        complete: BloggerFansModel.fromJson,
      );
      return resp ?? [];
    } catch (e) {
      return null;
    }
  }

  Future<bool?> joinGroup(int groupId, int ticketType) async {
    try {
      await httpInstance.post(
        url: 'bloggerFansGroup/join',
        body: {'groupId': groupId, 'ticketType': ticketType},
      );
      return true;
    } catch (e) {
      return null;
    }
  }
}
